<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:replace="common/head"/>
</head>
<body>
<div class="x-body">
    <form class="layui-form" style="padding-bottom: 10px;text-align: left;">
        用户名：
        <div class="layui-inline">
            <input class="layui-input" type="text" name="userName" autocomplete="on" placeholder="查询字段值">
        </div>
        用户类型：
        <div class="layui-inline">
            <select name="userType" lay-search="">
                <option value="">直接选择或搜索选择</option>
                <th:block th:each="map: ${userType}">
                    <option th:value="${map.key}" th:text="${map.value}"></option>
                </th:block>
            </select>
        </div>
        门店名：
        <div class="layui-inline">
            <input class="layui-input" type="text" name="shopName" autocomplete="on" placeholder="查询字段值">
        </div>
        用户状态：
        <div class="layui-inline">
            <select name="status" lay-search="">
                <option value="">直接选择或搜索选择</option>
                <option th:value="0" th:text="失效"></option>
                <option th:value="1" th:text="正常"></option>
            </select>
        </div>
        <button class="layui-btn" lay-submit lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
    </form>

    <xblock>
        <button class="layui-btn layui-btn-normal dialog" data-url="/user/toAdd" data-width="900"
                data-height="700" data-title="添加">
            <i class="layui-icon">&#xe608;</i>添加
        </button>
    </xblock>

    <input type="hidden" id="editText" value="user/editText">
    <input type="hidden" id="checkboxUpdate" value="user/checkboxUpdate">
    <input type="hidden" id="myEntityId" value="userId">

    <table class="layui-table"
           lay-data="{url:'/user/list', page:true,id:'table',limit:15,limits:[10,15,20,50,100]}"
           lay-filter="table">
        <thead>
        <tr>
            <!--<th lay-data="{field:'demo',align:'center', sort: true, edit:'text',templet:'#templetId'}">demo</th>-->
            <!--<th lay-data="{checkbox:true, fixed: true}"></th>-->

            <th lay-data="{field:'userId',align:'center', sort: true}">userId</th>
            <th lay-data="{field:'userName',align:'center',edit:'text', sort: true}">姓名</th>
            <th lay-data="{field:'userType',align:'center',templet:'#userType'}">用户类型</th>
            <th lay-data="{field:'shopName',align:'center',edit:'text',}">门店名</th>
            <th lay-data="{field:'userImg',align:'center',templet:'#userImg'}">头像</th>
            <th lay-data="{field:'address',align:'center',edit:'text',}">地址</th>
            <th lay-data="{field:'addressTwo',align:'center',edit:'text',}">地址2</th>
            <th lay-data="{field:'phone',align:'center',edit:'text',}">电话</th>
            <th lay-data="{field:'phoneTwo',align:'center',edit:'text',}">电话2</th>
            <th lay-data="{field:'status',align:'center',templet:'#status'}">状态</th>
            <th lay-data="{field:'remark',align:'center',edit:'text'}">备注</th>
            <th lay-data="{fixed:'right', align:'center', width:150, toolbar: '#row-bar'}">操作</th>
        </tr>
        </thead>
    </table>

    <script type="text/html" id="userType" th:inline="javascript">
        {{#  var map = [[${userType}]] }}
        {{#  for(var key in map){ }}
        {{#     if(d.userType == key){ }}
        {{         unescape(map[key].replace(/\\u/g, '%u')) }}
        {{#     } }}
        {{#  } }}
    </script>

    <script type="text/html" id="userImg">
        {{#  if(d.userImg != '' && d.userImg != null){ }}
        <img src="{{d.userImg}}" alt="{{d.userName}}">
        {{#  } else { }}
        {{#  } }}
    </script>

    <script type="text/html" id="status">
        <input type="checkbox" name="status" value="{{d.userId}}" lay-skin="switch" lay-text="正常|失效" lay-filter="checkbox" {{ d.status == 1 ? 'checked' : '' }}
    </script>


    <script type="text/html" id="row-bar">
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit" data-id="userId" data-url="/user/toEdit" data-title="编辑" data-width="800"
           data-height="600"><i class="layui-icon">&#xe642;</i> 编辑</a>
    </script>
</div>
<div th:replace="common/js"></div>
<div th:replace="common/setting"></div>
<script type="text/javascript">
    layui.use('xtable');
</script>
</body>
</html>
